#lang racket/base
(require racket/function
		 "core.rkt")

(define (test1)
  (rx+ (create-observable (lambda (sub)
							(rx* sub
								 (on-next 1)
								 (on-next 2)
								 (on-next 3)
								 (on-next 4)
								 (on-completed))))
	   (map (curry + 3))
	   (map (curry * 2))
	   (filter (curry < 10))
	   (subscribe (lambda (x) (displayln x))
				  (lambda (e) (displayln e))
				  (lambda () (displayln "completed")))))

(define (test2)
  (define count (box 0))
  (rx+ (interval 0.1)
	   (map (lambda (x)
			  (set-box! count (add1 (unbox count)))
			  (unbox count)))
	   (take 100)
	   (debounce 2.0001)
	   (subscribe displayln void (thunk (displayln "completed")))))
